package com.wdhcr.service.imp;


import com.wdhcr.entity.Photo;
import com.wdhcr.repository.PhotoRepository;
import com.wdhcr.service.PhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class PhotoServiceImpl implements PhotoService {

    @Autowired
    private PhotoRepository photoRepository;


    @Override
    public Photo savePhoto(Photo photo) {
        return photoRepository.save(photo);
    }

    @Override
    public Page<Photo> listPhoto(Pageable pageable) {
        return photoRepository.findAll(pageable);
    }

    @Override
    public Page<Photo> findPhoto(Pageable pageable) {
        return photoRepository.findPhoto(pageable);
    }

    @Override
    public Photo getPhoto(Long id) {
        return photoRepository.getOne(id);
    }


    @Override
    public void delete(Long id) {
        photoRepository.deleteById(id);
    }
}
